package com.janj.T;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

//测试类
public class JanJ {
    public static void main(String[] args) {
        //找到我们的家人
        Gril family = new duoduo();

        //进行代理操作
        Gril mother = (Gril) Proxy.newProxyInstance(
                family.getClass().getClassLoader(),
                family.getClass().getInterfaces(),
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        start();
                        Object fhz = method.invoke(family, args);
                        end();
                        return fhz;
                    }

                }

        );
        mother.eat();
        mother.movie();

    }

    public static void start() {
        System.out.println("妈妈问:有没有房?有没有车");
    }

    public static void end() {
        System.out.println("妈妈问:他有没有对你动手动脚");
    }

}
